package com.study.a04udpdemo3;

import java.io.IOException;
import java.net.DatagramPacket;
import java.net.InetAddress;
import java.net.MulticastSocket;

public class SendMessageDemo {
    public static void main(String[] args) throws IOException {

        //创建MulticastSocket对象（快递公司）
        MulticastSocket ms=new MulticastSocket();
        String s="hello";
        byte[] bytes=s.getBytes();

        //组播地址：224.0.0.1~239.255.255.255
        //广播地址：255.255.255.255
        InetAddress address=InetAddress.getByName("224.0.0.1");

        int port=10000;

        DatagramPacket dp=new DatagramPacket(bytes,bytes.length,address,port);

        ms.send(dp);

        ms.close();
    }
}
